package com.oe.code.service;

import com.oe.code.CodeService;
import com.oe.code.dao.LagouAuthCodeDao;
import com.oe.code.model.LagouAuthCode;
import com.oe.code.req.CheckCodeReq;
import com.oe.code.resp.CheckCodeResp;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class CodeServiceImpl implements CodeService {

    @Autowired
    LagouAuthCodeDao lagouAuthCodeDao;

    public Boolean createCode(String email) {
        return Boolean.TRUE;
    }

    public CheckCodeResp checkCode(CheckCodeReq req) {
        CheckCodeResp resp = new CheckCodeResp();
        LagouAuthCode lagouAuthCode = lagouAuthCodeDao.selectOneByCodeAndAndEmail(req.getCode(), req.getEmail());
        if(lagouAuthCode==null){
            resp.setSuccess(Boolean.FALSE);
        }else {
            resp.setSuccess(Boolean.TRUE);
        }
        return resp;
    }
}
